﻿#ifndef IICTABLEWIDGET_H
#define IICTABLEWIDGET_H

#include "components/CustomTableWidget/CustomTableWidget.h"
#include "services/tlv/Base/iic.h"
#include "stores/TlvProject/TlvDataModelTypeDef.h"

class IICTableWidget : public CustomTableWidget
{
    Q_OBJECT
public:
    explicit IICTableWidget(QWidget *parent = nullptr);

    void addIICCmd(const QString& desc, const QString& addr, const QString& data, const QString& readLen, const QString& waitMs="50");
    void addIICCmd(const QString& desc, uint8_t addr, const QByteArray& data, uint8_t readLen, uint16_t waitMs=50);
    void addIICCmd(const QString& desc, const IIC& iic, const QString& waitMs="50");
    void addIICCmd(const QString& desc, const IIC& iic, uint16_t waitMs=50);
    void addNewLine();
    void insertNewLine(int row);

    bool getRowIIC(int row, IIC* oIic, uint16_t* oWaitMs);

    static QString onPasteHexCallback(const QString& input);

    QList<IICCmdModel> toIICCmdModel();

public slots:
    void sendIIC(int row);
    bool sendSelected();

protected:
    void insertIICCmd(int row, const QString& desc, const QString& addr, const QString& data, const QString& readLen, const QString& waitMs="50");
};

#endif // IICTABLEWIDGET_H
